package main

import (
	"bridge_viewing/component"
	"bridge_viewing/config"
	"bridge_viewing/db"
	"bridge_viewing/global"
	router "bridge_viewing/route"
	"fmt"
	"os"
	"path/filepath"
)

func main() {
	if workDir, err := filepath.Abs(filepath.Dir(os.Args[0])); err != nil {
		_ = fmt.Errorf("Load workspace fail, stop !!!!!!!!!!!!!!")
		return
	} else {
		global.InitViperConfig(workDir, config.ServerGlobalConfig)
		// 设置日志配置并且初始化
		global.InitLoginConfig(config.ServerGlobalConfig.LoggerConfig.MaxAge)
		global.GetLogger().Info("Init Config Success")
		db.InitDB()
		global.GetLogger().Info("Start DB Client Success")
		component.Init(config.ServerGlobalConfig)
		router.InitRouter(workDir)
	}
}
